package birdry.game.sadari
{
	
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	* ...
	* @author 
	*/
	public class SadariBaseLine	{
		
		private var _view:Sprite;
		private var _baseLineArr:Array;
		private var _colLineMargin:uint = 50;
		private var _rowLineMargin:uint = 50;
		private var _lineColor:uint = 0xffffff;
		private var _lineThickness:uint = 2;
		
		public function setLineColor(color:uint): void	{
			_lineColor = color;
		}
		
		public function setLineThickness(thickness:uint): void	{
			_lineThickness = thickness;
		}
		
		public function get view(): Sprite	{
			return _view;
		}
		
		
		public function draw(baseLineArr:Array, isHidden:Boolean): void	{
			_baseLineArr = baseLineArr;
			drawBaseLine(isHidden);
		}
		
		public function SadariBaseLine( colLineMargin:uint = 50, rowLineMargin:uint = 50 )	{
			_colLineMargin = colLineMargin;
			_rowLineMargin = rowLineMargin;
			_view = new Sprite();
		}
		
		private function drawBaseLine( isHidden:Boolean ):void 		{
			view.graphics.clear();
			var i:uint;
			for ( i = 0; i < _baseLineArr[0].length+1; ++i)	{
				drawColLine(i);
			}
			if (isHidden)	return;
			for (i = 0; i < _baseLineArr.length; ++i)	{
				for (var u:uint = 0; u < _baseLineArr[i].length; ++u)	{
					drawRowLine(u, i);
				}
			}
		}
		
		private function drawRowLine(row:uint, col:uint):void 		{
			if (_baseLineArr[col][row] == 0)	return;
			view.graphics.lineStyle(_lineThickness, _lineColor, 1, false);
			view.graphics.moveTo(row * _colLineMargin, (col * _rowLineMargin + _rowLineMargin));
			view.graphics.lineTo(row * _colLineMargin + _colLineMargin, (col * _rowLineMargin + _rowLineMargin));
		}
		
		private function drawColLine(num:uint):void		{
			var _x:Number = _colLineMargin * num;
			view.graphics.lineStyle(_lineThickness, _lineColor, 1, false);
			view.graphics.moveTo(_x, 0);
			view.graphics.lineTo(_x, _rowLineMargin * _baseLineArr.length + _rowLineMargin);
		}
		
		
		
	}	// class
	
}	// package